package com.example.testcourse3;

import java.util.Random;

public class GuessGame {
    private int randomNumber;
    private int numberOfGuesses;

    public GuessGame() {
        generateRandomNumber();
        numberOfGuesses = 0;
    }

    private void generateRandomNumber() {
        Random random = new Random();
        randomNumber = random.nextInt(100) + 1; // 生成1-100之间的随机数
    }

    public int getRandomNumber() {
        return randomNumber;
    }

    public int getNumberOfGuesses() {
        return numberOfGuesses;
    }

    public String checkGuess(int userGuess) {
        numberOfGuesses++;
        if (userGuess == randomNumber) {
            return "正确";
        } else if (userGuess < randomNumber) {
            return "太低";
        } else {
            return "太高";
        }
    }

    public void resetGame() {
        generateRandomNumber();
        numberOfGuesses = 0;
    }
}
